#include <stdio.h>

#define IN       1   /* inside a word */
#define OUT      0   /* outside a word */
#define CHARS   95   /* number of printable characters in ASCII */
#define SP    0x20   /* ASCII code for space character
                        (first printable character) */
#define TIL   0x7e   /* ASCII code for tilde 
                        (last printable character) */
#define H       40   /* maximum horizontal size of histogram */

/* prints a horizontal histogram of the characters in input */
main(){
    int i, j, c, K, state;
    long ch[CHARS];

    state = OUT;
    
    for(i=0; i<CHARS; ++i)
        ch[i]=0;
    
    while((c = getchar()) != EOF)
        if(c >= SP && c <= TIL)
            ++ch[c-SP];
    
    for(i=0; i<CHARS; ++i){
        if(ch[i]>0){
            printf("Printable character '%c': %ld ", i+SP, ch[i]);
            if(ch[i]<=H)
                K = ch[i];
            else
                K = H;
            for(j=0; j<K; ++j)
                putchar('*');
            putchar('\n');
        }
    }
    printf("No other printable characters appeared in input.\n");
}
